package yunwo.cn.yzstation.model;

import android.util.Log;

import com.google.gson.Gson;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;
import yunwo.cn.yzstation.api.HttpManager;
import yunwo.cn.yzstation.api.OrderDetailsModel;
import yunwo.cn.yzstation.api.okapi.GLCallBack;
import yunwo.cn.yzstation.bean.OrderDetailsBean;
import yunwo.cn.yzstation.config.MyConstants;
import yunwo.cn.yzstation.view.activity.OrderDetailsActivity;

/**
 * Created by lao on 2017/9/14.
 */
public class OrderDetailsActivityModel {
    OrderDetailsActivity orderDetailsActivity;
    OrderDetailsModel orderDetailsModel;
    public OrderDetailsActivityModel(OrderDetailsActivity orderDetailsActivity, OrderDetailsModel orderDetailsModel) {
        this.orderDetailsActivity = orderDetailsActivity;
        this.orderDetailsModel = orderDetailsModel;
    }

    public void getDatailsData(String trackingId) {
        Map<String, String> map = new HashMap<>();
        map.put("params", trackingId);
        HttpManager.hpptPostString(MyConstants.Inventory_details,map).execute(new GLCallBack() {
            @Override
            public void onResponseT(String result, int code, String msg, int id) {
                if (code == 200) {
                    if (!result.equals("")) {
                        OrderDetailsBean.DataBean dataBean = new Gson().fromJson(result, OrderDetailsBean.DataBean.class);
                        orderDetailsModel.getOrderDetailsSuccess(dataBean);
                    }
                }
            }

            @Override
            public void onError(Call call, Exception e, int id) {
                Log.d("xxxxxxxxx", e.toString());
            }
        });

    }
}
